import { createI18n } from 'vue-i18n'
import { 
  login as loginLocales, 
  register as registerLocales, 
  verifyEmail as verifyEmailLocales, 
  resetPassword as resetPasswordLocales,
  studentHome as studentHomeLocales,
  enterpriseHome as enterpriseHomeLocales,
  resume as resumeLocales,
  applications as applicationsLocales,
  message as messageLocales,
  home as homeLocales,
  accountSettings as accountSettingsLocales,
  enterpriseDemand as enterpriseDemandLocales,
  enterpriseCertification as enterpriseCertificationLocales,
  enterpriseSpace as enterpriseSpaceLocales,
  applicationRecords as applicationRecordsLocales,
  enterpriseMessage as enterpriseMessageLocales,
  enterpriseAccountSettings as enterpriseAccountSettingsLocales,
  talentSearch as talentSearchLocales
} from './locales/index.js'

// 中文语言包
const zh = {
  // 根级别键值
  userCenter: '个人中心',
  
  // 通用
  common: {
    loading: '加载中...',
    confirm: '确认',
    cancel: '取消',
    save: '保存',
    delete: '删除',
    edit: '编辑',
    add: '添加',
    search: '搜索',
    submit: '提交',
    reset: '重置',
    back: '返回',
    next: '下一步',
    previous: '上一步',
    close: '关闭',
    open: '打开',
    yes: '是',
    no: '否',
    success: '成功',
    error: '错误',
    warning: '警告',
    info: '信息',
    and: '和',
    reply: '回复',
    
    // 确认对话框
    warning: '警告',
    confirm: '确定',
    cancel: '取消',
    close: '关闭',
    save: '保存',
    edit: '编辑',
    delete: '删除',
    add: '添加',
    search: '搜索',
    submit: '提交',
    reset: '重置',
    refresh: '刷新',
    loading: '加载中...',
    success: '成功',
    error: '错误',
    info: '信息',
    warning: '警告',
    
    // 状态
    online: '在线',
    offline: '离线',
    active: '活跃',
    inactive: '非活跃',
    enabled: '启用',
    disabled: '禁用',
    
    // 时间
    today: '今天',
    yesterday: '昨天',
    tomorrow: '明天',
    thisWeek: '本周',
    lastWeek: '上周',
    nextWeek: '下周',
    thisMonth: '本月',
    lastMonth: '上月',
    nextMonth: '下月',
    thisYear: '今年',
    lastYear: '去年',
    nextYear: '明年'
  },
  
  // 首页
  home: homeLocales.zh,
  
  // 企业端首页
  enterpriseHome: enterpriseHomeLocales.zh,
  
  // 登录页面
  login: loginLocales.zh,
  
  // 注册页面
  register: registerLocales.zh,
  
  // 邮箱验证页面
  verifyEmail: verifyEmailLocales.zh,
  
  // 重置密码页面
  resetPassword: resetPasswordLocales.zh,
  
  // 学生中心页面
  studentHome: studentHomeLocales.zh.studentHome,
  

  
  // 用户首页
  userHome: studentHomeLocales.zh.userHome,
  
  // 个人中心页面
  profile: studentHomeLocales.zh.profile,
  
  // 简历页面
  resume: resumeLocales.zh,
  // 申请中心页面
  applications: applicationsLocales.zh,
  // 消息中心页面
  message: messageLocales.zh,
  

  
  // 头部导航
  header: {
    studentCenter: '学生中心',
    enterpriseCenter: '企业中心',
    logout: '退出',
    logoutSuccess: '已退出登录'
  },
  
  // 表单验证
  validation: {
    required: '此字段为必填项',
    email: '请输入有效的邮箱地址',
    minLength: '最少输入 {min} 个字符',
    maxLength: '最多输入 {max} 个字符',
    passwordStrength: '密码必须包含大小写字母、数字和特殊字符',
    passwordMatch: '两次输入密码不一致',
    // 具体密码强度要求
    passwordTooShort: '密码长度至少8位',
    passwordMissingLower: '密码必须包含小写字母',
    passwordMissingUpper: '密码必须包含大写字母',
    passwordMissingNumber: '密码必须包含数字',
    passwordMissingSpecial: '密码必须包含特殊字符'
  },
  
  // 账号设置页面
  accountSettings: accountSettingsLocales.zh,
  
  // 企业需求页面
  enterpriseDemand: enterpriseDemandLocales.zh,
  
  // 企业中心页面
  enterpriseSpace: enterpriseSpaceLocales.zh,
  
  // 企业申请记录页面
  enterpriseApplicationRecords: applicationRecordsLocales.zh,
  
  // 企业消息中心页面
  enterpriseMessageCenter: enterpriseMessageLocales.zh,
  
  // 企业账号设置页面
  enterpriseAccountSettings: enterpriseAccountSettingsLocales.zh,
  
  // 企业人才库页面
  enterpriseTalentSearch: talentSearchLocales.zh,
  
  // 企业认证页面
  enterpriseCertification: enterpriseCertificationLocales.zh.certification,
  
  // 企业认证申请页面
  enterpriseCertificationForm: enterpriseCertificationLocales.zh.certificationForm
}

// 英文语言包
const en = {
  // 根级别键值
  userCenter: 'User Center',
  
  // Common
  common: {
    loading: 'Loading...',
    confirm: 'Confirm',
    cancel: 'Cancel',
    save: 'Save',
    delete: 'Delete',
    edit: 'Edit',
    add: 'Add',
    search: 'Search',
    submit: 'Submit',
    reset: 'Reset',
    back: 'Back',
    next: 'Next',
    previous: 'Previous',
    close: 'Close',
    open: 'Open',
    yes: 'Yes',
    no: 'No',
    success: 'Success',
    error: 'Error',
    warning: 'Warning',
    info: 'Info',
    and: 'and',
    reply: 'Reply'
  },
  
  // Home page
  home: homeLocales.en,
  
  // Enterprise Home page
  enterpriseHome: enterpriseHomeLocales.en,
  
  // Login page
  login: loginLocales.en,
  
  // Register page
  register: registerLocales.en,
  
  // Email verification page
  verifyEmail: verifyEmailLocales.en,
  
  // Reset password page
  resetPassword: resetPasswordLocales.en,
  
  // Student home page
  studentHome: studentHomeLocales.en.studentHome,
  

  
  // User Home Page
  userHome: studentHomeLocales.en.userHome,
  
  // Profile Page
  profile: studentHomeLocales.en.profile,
  
  // Resume Page
  resume: resumeLocales.en,
  // 申请中心页面
  applications: applicationsLocales.en,
  // 消息中心页面
  message: messageLocales.en,
  
  // Common text
  common: {
    // 确认对话框
    warning: 'Warning',
    confirm: 'Confirm',
    cancel: 'Cancel',
    close: 'Close',
    save: 'Save',
    edit: 'Edit',
    delete: 'Delete',
    add: 'Add',
    search: 'Search',
    submit: 'Submit',
    reset: 'Reset',
    refresh: 'Refresh',
    loading: 'Loading...',
    success: 'Success',
    error: 'Error',
    info: 'Info',
    warning: 'Warning',
    
    // 基本操作
    back: 'Back',
    next: 'Next',
    previous: 'Previous',
    open: 'Open',
    yes: 'Yes',
    no: 'No',
    and: 'and',
    
    // Status
    online: 'Online',
    offline: 'Offline',
    active: 'Active',
    inactive: 'Inactive',
    enabled: 'Enabled',
    disabled: 'Disabled',
    
    // Time
    today: 'Today',
    yesterday: 'Yesterday',
    tomorrow: 'Tomorrow',
    thisWeek: 'This Week',
    lastWeek: 'Last Week',
    nextWeek: 'Next Week',
    thisMonth: 'This Month',
    lastMonth: 'Last Month',
    nextMonth: 'Next Month',
    thisYear: 'This Year',
    lastYear: 'Last Year',
    nextYear: 'Next Year'
  },
  
  // Header navigation
  header: {
    studentCenter: 'Student Center',
    enterpriseCenter: 'Enterprise Center',
    logout: 'Logout',
    logoutSuccess: 'Logged out successfully'
  },
  
  // Form validation
  validation: {
    required: 'This field is required',
    email: 'Please enter a valid email address',
    minLength: 'Minimum {min} characters required',
    maxLength: 'Maximum {max} characters allowed',
    passwordStrength: 'Password must contain uppercase, lowercase, numbers and special characters',
    passwordMatch: 'Passwords do not match',
    // Specific password strength requirements
    passwordTooShort: 'Password must be at least 8 characters',
    passwordMissingLower: 'Password must contain lowercase letters',
    passwordMissingUpper: 'Password must contain uppercase letters',
    passwordMissingNumber: 'Password must contain numbers',
    passwordMissingSpecial: 'Password must contain special characters'
  },
  
  // 账号设置页面
  accountSettings: accountSettingsLocales.en,
  
  // 企业需求页面
  enterpriseDemand: enterpriseDemandLocales.en,
  
  // 企业中心页面
  enterpriseSpace: enterpriseSpaceLocales.en,
  
  // 企业申请记录页面
  enterpriseApplicationRecords: applicationRecordsLocales.en,
  
  // 企业消息中心页面
  enterpriseMessageCenter: enterpriseMessageLocales.en,
  
  // 企业账号设置页面
  enterpriseAccountSettings: enterpriseAccountSettingsLocales.en,
  
  // 企业人才库页面
  enterpriseTalentSearch: talentSearchLocales.en,
  
  // 企业认证页面
  enterpriseCertification: enterpriseCertificationLocales.en.certification,
  
  // 企业认证申请页面
  enterpriseCertificationForm: enterpriseCertificationLocales.en.certificationForm
}

// 创建i18n实例
const i18n = createI18n({
  legacy: false, // 使用Composition API模式
  locale: 'zh', // 默认语言，不使用localStorage，让组件自己控制
  fallbackLocale: 'zh', // 回退语言
  messages: {
    zh,
    en
  }
})

export default i18n 